home *** CD-ROM | disk | FTP | other *** search
- Path: lonestar.jpl.utsa.edu!nreitzel
- From: nreitzel@lonestar.jpl.utsa.edu (Norman L. Reitzel )
- Newsgroups: comp.lang.c
- Subject: Re: #define "creating" strings ?
- Date: 14 Mar 1996 22:18:55 GMT
- Organization: University of Texas at San Antonio
- Message-ID: <4ia60f$dhq@ringer.cs.utsa.edu>
- References: <Do9tsI.H2t@undergrad.math.uwaterloo.ca>
- NNTP-Posting-Host: lonestar.jpl.utsa.edu
-
- In article <Do9tsI.H2t@undergrad.math.uwaterloo.ca> crpalmer@solo.uwaterloo.ca (Chris Palmer) writes:
- >I have a problem that I would like to solve using a "feature" of the C
- >preprocessor that until now I've never seen or heard of. A book that we have
- >here gives the example:
- >
- >#define MAKESTRING(x) "x"
- >
- >which does in fact produce strings that have the value of x substituted.
- >[eg: MAKESTRING(foo) gets processed into "foo"].
- >
- >I've verified this on a DEC Alpha (cc) and the GNU C compiler..
- >
- >Is this in fact a supported behaviour that should be portable to most
- >C compilers?
-
- Sure. Why is this surprizing? The preprocessor performs character
- string substitution, a la M4. It doesn't care if it's assembling a
- string with quotes or a syntactic disaster.
-
- IMHO, this is an error prone practice, in a language that is ripe with
- things that can be error prone. Why would one want to substitute the
- expression MAKESTRING(nuts) for the equivalent and obvious syntax, "nuts" ?
-
-
-
- --
- Norman L. Reitzel, Jr. | "When you live beside the graveyard,
- nreitzel@lonestar.utsa.edu | you can't cry for every funeral."
- Blue Water Ventures, dba. | Russian Proverb
-